import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';

export type UserDocument = User & Document;

@Schema()
export class User {
  @Prop({ required: false, type: Types.ObjectId })
  _id: Types.ObjectId;

  @Prop({ required: true, unique: true })
  username: string;

  @Prop({ required: true })
  password: string;

  @Prop({ required: false, unique: false })
  avatar: string;

  @Prop({ required: false, unique: false })
  certified_driver: boolean;

  @Prop({ required: false, unique: true })
  score: number;

  @Prop({ required: false, unique: true })
  settledTime: Date;

  @Prop({ required: false, unique: true })
  updateTime: Date;
}

export const UserSchema = SchemaFactory.createForClass(User);